<template>
  <div class="container-login">
          <img class="logo" src="../assets/login-logo.png" alt="">

    <div class="tabel-area">
      <el-form ref="userform" :model="user" label-width="80px" :rules="rules">
        <el-form-item label="姓名" prop="name">
          <el-input type="text" v-model="user.name"></el-input>
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input type="text" v-model.number="user.age"></el-input>
        </el-form-item>

        <el-form-item label="身高" prop="height">
          <el-input type="text" v-model.number="user.height" >
                <template slot="append">CM</template>
          </el-input>
        </el-form-item>
        <el-form-item label="体重" prop="weight">
          <el-input type="text" v-model.number="user.weight" >
            <template slot="append">KG</template>
          </el-input>
        </el-form-item>
        <el-form-item label="性别" prop="gender">
          <el-radio-group v-model="user.gender" text-color="#000000" fill="red"	>
            <el-radio label="男"></el-radio>
            <el-radio label="女"></el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
        <div class="button-area">
          <el-button class="cacel-button">取消</el-button>
          <el-button class="login-button" @click="onSubmit('userform')">登录</el-button>
        </div>
    </div>

  </div>
</template>
<script>
export default {
  data() {
    return {
      user: {
        name: "",
        age: "",
        height: "",
        weight: "",
        gender: "",
      },
      rules: {
        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        age: [{ required: true, message: "请输入年龄", trigger: "blur" },{ type: 'number', message: '年龄必须为数字值'}],
        height: [{ required: true, message: "请输入身高", trigger: "blur" },{ type: 'number', message: '身高必须为数字值'}],
        weight: [{ required: true, message: "请输入体重", trigger: "blur" },{ type: 'number', message: '体重必须为数字值'}],
        gender: [{ required: true, message: "请选择性别", trigger: "blur" }],
      },
    };
  },
  methods: {
    onSubmit(userform) {
      this.$refs[userform].validate((valid) => {
        if (valid) {
          localStorage.setItem("userMsg", JSON.stringify(this.user));
          this.$router.push({ name: "Meau" });
          console.log('第一次登陆时会清除历史数据')
          localStorage.removeItem('result')
        } else {

          this.$alert("请正确输入参数",{});
          return false;
        }
      });
    },
  },

};
</script>

<style lang="less">
.el-form-item__label {
  color:white
}
.el-radio__input.is-checked .el-radio__inner {
    border-color: #409EFF;
    background: #b9e3e3;
}
.el-form-item__label{
  font-size: 25px;
}
.el-radio__label{
  color: white;
}
.el-radio__label{
 font-size: 25px; 
}
.el-radio__input.is-checked+.el-radio__label {
  color: #FFFFFF;
}
.el-form-item__error{
    font-family: PingFangSC-Medium, PingFang SC;

    color: hsl(0deg 100% 50%);
    font-size: 12px;
    line-height: 1;
    padding-top: 4px;
    position: absolute;
    top: 100%;
    left: 0;
}
.container-login {
  background: url('../assets/background.png');
  padding-top: 20vh;
  width: 100%;
  height: 80vh;
  display: flex;
  justify-content: center;
  .logo{
      width: 449px;
      height: 350px;
  }
  .tabel-area{
    margin-left: 30px;
    width: 600px;
    
    .cacel-button{
      width: 280px;
      height: 100px;
      background: #D9ECF3;
      border-radius: 8px;
      font-size: 44px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
    }
    .login-button{
      width: 280px;
      height: 100px;
      background: linear-gradient(170deg, #37BE98 0%, #0F7DDF 100%);
      border-radius: 8px;
      font-size: 44px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #FFFFFF;
      border: 0;
    }
    .button-area{
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
  .el-radio-group{
    padding-left: 20px;
  }
}
</style>